<template>
  <div class="evaluate-system">
    <el-form
      style="background: #fff; padding: 20px"
      ref="form"
      :model="form"
      label-width="380px"
      label-position="left"
    >
      <el-form-item
        v-for="item in formTemplate"
        :key="item.bindKey"
        :label="item.label"
      >
        <el-input-number
          v-model="form[item.bindKey]"
          :min="0"
          :max="1"
          :step="0.1"
        ></el-input-number>
      </el-form-item>
      <el-form-item label="原理知识掌握能力分析中学习时间指标(单位小时)">
        <el-input-number
          v-model="form.theory_mastery_Q"
          :min="1"
          :max="10"
          :step="1"
        ></el-input-number>
      </el-form-item>

      <el-form-item>
        <el-button @click="clear" type="danger">清空</el-button>
        <el-button @click="onSubmit" type="primary">确定</el-button>
      </el-form-item>
    </el-form>
    <div class="right">
      <dynamic-tags
        :title="'学位背景列表'"
        :items="items1"
        :saveMethod="save1"
      ></dynamic-tags>
      <dynamic-tags
        :title="'岗位背景列表'"
        :items="items2"
        :saveMethod="save2"
      ></dynamic-tags>
    </div>
  </div>
</template>

<script>
import { getWeights, setWeights } from "@/services/admin/evaluate";
import { Message } from "element-ui";
import DynamicTags from "@/components/DynamicTags.vue";
import {
  setAcademicBackground,
  setPositionBackground,
  getAcademicBackground,
  getPositionBackground,
} from "@/services/auth";
export default {
  components: { DynamicTags },
  name: "EvaluateSystem",
  data() {
    return {
      formTemplate: [
        {
          bindKey: "students_teacher",
          label: "学员对教员进行的评分占教员总评分的比例",
        },
        {
          bindKey: "teachers_teacher",
          label: "教员对教员进行的评分占教员总评分的比例",
        },
        {
          bindKey: "admins_teacher",
          label: "管理员对教员进行的评分占教员总评分的比例",
        },
        {
          bindKey: "students_arrangement",
          label: "学员对课程安排的评分占安排总评分的比例",
        },
        {
          bindKey: "teachers_arrangement",
          label: "教员对课程安排的评分占安排总评分的比例",
        },
        {
          bindKey: "admins_arrangement",
          label: "管理员对课程安排的评分占安排总评分的比例",
        },
        {
          bindKey: "students_material",
          label: "学员对教材进行的评分占教材总评分的比例",
        },
        {
          bindKey: "teachers_material",
          label: "教员对教材进行的评分占教材总评分的比例",
        },
        {
          bindKey: "admins_material",
          label: "管理员对教材进行的评分占教材总评分的比例",
        },
        {
          bindKey: "students_environment",
          label: "学员对教学环境的评分占环境总评分的比例",
        },
        {
          bindKey: "teachers_environment",
          label: "教员对教学环境的评分占环境总评分的比例",
        },
        {
          bindKey: "admins_environment",
          label: "管理员对教学环境的评分占环境总评分的比例",
        },
        {
          bindKey: "quality_academic",
          label: "学习素质评估中,学业背景评分占比",
        },
        {
          bindKey: "quality_position",
          label: "学习素质评估中,岗位背景评分占比",
        },
        {
          bindKey: "quality_theory",
          label: "学习素质评估中,理论学习掌握情况占比",
        },
        {
          bindKey: "quality_training",
          label: "学习素质评估中,操作技能掌握情况占比",
        },

        {
          bindKey: "competency_self",
          label: "胜任能力评估中,自我评价分数占比",
        },
        {
          bindKey: "competency_mates",
          label: "胜任能力评估中,班组评价分数占比",
        },
        {
          bindKey: "competency_teachers",
          label: "胜任能力评估中,教员评价分数占比",
        },

        {
          bindKey: "learning_sit_academic",
          label: "学员个人学习情况评估:学业背景评分权重",
        },
        {
          bindKey: "learning_sit_position",
          label: "学员个人学习情况评估:岗位背景评分权重",
        },
        {
          bindKey: "learning_sit_theory",
          label: "学员个人学习情况评估:原理知识掌握权重",
        },
        {
          bindKey: "learning_sit_training",
          label: "学员个人学习情况评估:操作技能掌握权重",
        },
        {
          bindKey: "learning_sit_learning",
          label: "学员个人学习情况评估:训练素质权重",
        },
        {
          bindKey: "learning_sit_competency",
          label: "学员个人学习情况评估:胜任能力权重",
        },

        {
          bindKey: "theory_mastery_phi",
          label: "原理知识掌握能力分析中学习时间的比例",
        },
        // {
        //   bindKey: "theory_mastery_Q",
        //   label: "原理知识掌握能力分析中学习时间指标(单位小时)[1,10]",
        // },

        {
          bindKey: "course_difficulty",
          label: "课程得分计算中,课程难度反馈得分比率",
        },
        {
          bindKey: "course_perfection",
          label: "课程得分计算中,课程完善性反馈得分比率",
        },
      ],
      form: {},
      items1: [
        { text: "列表项1" },
        { text: "列表项2" },
        { text: "列表项3" },
        { text: "列表项4" },
      ],
      items2: [
        { text: "列表项1" },
        { text: "列表项2" },
        { text: "列表项3" },
        { text: "列表项4" },
      ],
    };
  },
  methods: {
    onSubmit() {
      setWeights(this.form).then((res) => {
        if (res.data.code == 200) {
          Message.success("设置成功");
        }
      });
    },
    clear() {
      this.form = {};
    },
    save1() {
      const academics = this.items1.map((v) => v.text);
      setAcademicBackground(academics).then((res) => {
        if (res.data.code == 200) {
          Message.success("修改成功");
        }
      });
    },
    save2() {
      const positions = this.items2.map((v) => v.text);
      setPositionBackground(positions).then((res) => {
        if (res.data.code == 200) {
          Message.success("修改成功");
        }
      });
    },
  },
  mounted() {
    getWeights().then((res) => {
      this.form = res.data.data;
    });
    getAcademicBackground().then((res) => {
      this.items1 = res.data.data.map((v) => ({ text: v }));
    });
    getPositionBackground().then((res) => {
      this.items2 = res.data.data.map((v) => ({ text: v }));
    });
  },
};
</script>
<style lang='less' scoped>
.evaluate-system {
  display: flex;
  justify-content: space-around;
  .el-form {
    width: 48%;
  }
  .right {
    width: 48%;
  }
}
</style>